package com.asset.salesforce.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.hibernate.annotations.Type;

import com.asset.salesforce.jacksonConvertor.CustomDateSerializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@SuppressWarnings("serial")
@XmlRootElement
@Table(name="file")
@Entity
public class File  implements Serializable{
	@JsonInclude(Include.NON_NULL)
	private Integer id;
	@JsonInclude(Include.NON_NULL)
	private String name;
	@JsonInclude(Include.NON_NULL)
	private String type;
	@JsonInclude(Include.NON_NULL)
	private String extension;
	@JsonInclude(Include.NON_NULL)
	private Date dateCreated;
	@JsonInclude(Include.NON_NULL)
	private byte[] data;
	@JsonInclude(Include.NON_NULL)
	private String encode;

	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="file_id_seq")
	@SequenceGenerator(name="file_id_seq",sequenceName="file_id_seq",allocationSize=1)
	public Integer getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	/**
	 * @return the name
	 */
	@Column(name ="name")
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the type
	 */
	@Column(name="type")
	public String getType() {
		return type;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}
	/**
	 * @return the extension
	 */
	@Column(name="extention")
	public String getExtension() {
		return extension;
	}
	/**
	 * @param extension the extension to set
	 */
	public void setExtension(String extension) {
		this.extension = extension;
	}
	/**
	 * @return the dateCreated
	 */
	@Column(name="date_created")
	@JsonSerialize(using= CustomDateSerializer.class)
	public Date getDateCreated() {
		return dateCreated;
	}
	/**
	 * @param dateCreated the dateCreated to set
	 */
	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}
	@Type(type = "org.hibernate.type.BinaryType")
	@Column(name="data")
	public byte[] getData() {
		return data;
	}
	
	public void setData(byte data[]) {
		this.data = data;
	}
	
	@Column(name="encode")
	public String getEncode() {
		return encode;
	}
	public void setEncode(String encode) {
		this.encode = encode;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "{\"id\":\"" + id + "\",\"name\":\"" + name + "\",\"type\":\""
				+ type + "\",\"extension\":\"" + extension
				+ "\",\"dateCreated\":\"" + dateCreated + "\",\"data\":\""
				+ Arrays.toString(data) + "\",\"encode\":\"" + encode + "\"}";
	}
	
	

}
